[FE] Pahmi Alifya Bahri - pahmi1998@gmail.com - #299
Open
pahmi-alifya wants to merge 4 commits into
Open
Conversation
… price fetching - Add SwapForm component for handling token swaps - Create TokenSelect component for selecting currencies - Implement TokenIcon component for displaying token icons - Add CSS styles for the swap interface - Introduce hooks for managing swap form state and fetching prices - Add fallback prices for offline usage - Create utility functions for formatting amounts and loading prices - Set up TypeScript configuration for the project - Include SVG icon for wstETH token - Remove unused script file and legacy styles
…ions and usage instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Solutions for the 99Tech code challenge, applying for the Frontend Engineer
role. Problems 1–3 are attempted (Problems 4–5 are out of scope for this role
and left untouched).
sum_to_nimplementations (loop, closed-form formula,recursion) plus a
runTestCases()helper that checks all three against ashared set of inputs.
prices and real token icons, with input validation and a simulated submit
flow.
bugs/inefficiencies, plus a refactored version.
Problem 1 — Three ways to sum to n
src/problem1/sum_to_n.jssum_to_n_a: iterative loop — O(n) time, O(1) space.sum_to_n_b: Gauss' formulan*(n+1)/2— O(1) time, O(1) space.sum_to_n_c: recursion — O(n) time, O(n) call-stack space.runTestCases()runs all three against[0, 1, 5, 10, 100, 1000]andcross-checks the loop/formula versions against much larger values
(
1_000_000,12345678); the recursive version is intentionally skippedfor those, since it would overflow the call stack.
Run:
node src/problem1/sum_to_n.jsProblem 2 — Fancy Form (currency swap)
src/problem2/— Vite + React + TypeScript.interview.switcheo.com/prices.json; the feed hasduplicate/stale rows per currency, so only the latest positive-price entry
per currency is kept. A bundled snapshot (
src/prices.json) is the fallbackif the live fetch fails.
a currency without a matching icon falls back to an initials badge.
"calculate" step.
same token (enforced in the token picker itself).
over as the new input.
setTimeout) since there's no real backend, so theloading spinner on the submit button is visible before a success message.
hooks/useSwapForm.ts;SwapForm.tsxis purelypresentational.
Run:
cd src/problem2 && npm install && npm run devProblem 3 — Messy React
src/problem3/analysis.md12 issues identified, including a couple of real bugs (an undefined
lhsPriorityreference, and an inverted amount filter that keepszero/negative balances instead of positive ones), plus inefficiencies
(unstable
getPriority, unnecessaryuseMemodependency, a deadformattedBalancesvariable computed but never used,key={index}on areorderable list, etc.). A refactored version is included with an explanation
of each change.
Assumptions
n >= 0, consistent with "sum to n" having no natural meaningfor negative n; result stays under
Number.MAX_SAFE_INTEGERper the spec.WBTC/ETHstyle live prices are trusted as-is from the given endpoint without
additional slippage/fee modeling.